'''
Author: goog
Date: 2022-02-09 18:44:00
LastEditTime: 2022-04-20 16:57:55
LastEditors: goog
Description: 
FilePath: /TensorRT/Tools/utils.py
Time Limit Exceeded!
'''
import yaml
import uuid
import time
from datetime import datetime

class Utils(object):
    def __init__(self) -> None:
        # self.day = str(time.strftime('%Y%m%d'))
        # self.time = str(time.strftime('%H%M%S'))
        pass

    @staticmethod
    def yaml_parser(yaml_dir):
        if 'dev' in yaml_dir:
            config_main = yaml.load(open(yaml_dir.replace('-dev', '')), Loader=yaml.FullLoader)
            config_dev = yaml.load(open(yaml_dir), Loader=yaml.FullLoader)
            def _merge_yaml(config_main, config_dev):
                for k, v in config_dev.items():
                    config_main[k] = v
                return config_main
            config = _merge_yaml(config_main, config_dev)
        else:
            config = yaml.load(open(yaml_dir), Loader=yaml.FullLoader)
        return config

    @staticmethod
    def get_uuid():
        return str(uuid.uuid1())
    
    @staticmethod
    def current_time():
        return str(time.strftime('%Y%m%d'))
    
    @staticmethod
    def current_time_second():
        return str(datetime.now().strftime('%H%M%S%f')) # datetime.now().strftime
            